Skip to content

fix: reject non-finite values from digit overflow path#10

Merged
ruoka merged 1 commit into
masterfrom
cursor/critical-bug-management-bb78
Jul 20, 2026
Merged

fix: reject non-finite values from digit overflow path#10
ruoka merged 1 commit into
masterfrom
cursor/critical-bug-management-bb78

Conversation

@cursor

@cursor cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

json::parse accepted digit-only magnitudes beyond the IEEE-754 double range (~310+ digits, e.g. 1 followed by 400 zeros) and stored ±infinity as a number value.

Impact: silent acceptance of non-JSON numeric values; downstream stringify can emit non-JSON (inf/-inf), and callers treating parsed numbers as finite doubles get corrupted data.

Root cause

The scientific-notation path already rejected non-finite pow results with std::isfinite, but decoder::integer_overflow (used when int64 overflows into float digit accumulation) did not. Multiplying m_number by 10 across enough digits overflows double to ±inf, which was then passed to m_builder.value.

Fix

  • Reject non-finite values during digit accumulation in integer_overflow
  • Reject again when finalizing float values in integer_overflow and fractions (covers overflow → fraction)

Validation

  • Added DigitOverflowToInfinityRejected covering positive, negative, and fractional oversized digit strings
  • ./tools/CB.sh debug test --tags='\[xson\]' — 403/403 passed
Open in Web View Automation 

Scientific notation already rejected ±inf/NaN, but integer_overflow
accepted ~310+ digit magnitudes as IEEE infinity. Guard digit
accumulation and finalize paths (including fraction) so parse fails
instead of storing non-JSON numeric values.

Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
@ruoka
ruoka marked this pull request as ready for review July 20, 2026 12:34
@ruoka
ruoka merged commit b4f22bf into master Jul 20, 2026
4 checks passed
ruoka added a commit that referenced this pull request Jul 21, 2026
Scientific notation already rejected ±inf/NaN, but integer_overflow
accepted ~310+ digit magnitudes as IEEE infinity. Guard digit
accumulation and finalize paths (including fraction) so parse fails
instead of storing non-JSON numeric values.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kaius  Ruokonen <ruoka@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants